<div class="panel panel-default">
  <div class="panel-heading">课程列表</div>
  <div class="panel-body">
    <div class="btn-group">
      <a href="<?= Yii::app()->createUrl('teacher/post_lesson') ?>" class="btn btn-success">添加</a>
      <button data-url="<?= Yii::app()->createUrl('teacher/lesson_gateway', array('state' => 1)) ?>"
              class="btn btn-warning">启用
      </button>
      <button data-url="<?= Yii::app()->createUrl('teacher/lesson_gateway', array('state' => 0)) ?>"
              class="btn btn-danger">禁用
      </button>
    </div>
    <p>
    <form action="<?= Yii::app()->createUrl('teacher/lesson') ?>" method="get" class="form-inline">
      <input type="text" name="keywords" id="keywords" style="width: 200px" class="form-control" placeholder="请输入课程名">
      <button type="submit" class="btn btn-info"><i class="fa fa-search"></i> 搜索</button>
    </form></p>
    <?php if (empty($data['list'])): ?>
      <p>暂时没有符合条件的课程</p>
    <?php else: ?>
      <table class="table table-hover">
        <tr>
          <th><input type="checkbox" id="checkAll"></th>
          <th>名称</th>
          <th>点击数</th>
          <th>状态</th>
          <th>创建时间</th>
          <th>编辑</th>
        </tr>
        <?php foreach ($data['list'] as $row): ?>
          <tr>
            <td><input type="checkbox" class="id" value="<?= $row->lesson_id ?>"></td>
            <td><?= CHtml::encode($row->name) ?></td>
            <td><?= CHtml::encode($row->hits) ?></td>
            <td>
              <?php if ($row->state == 1): ?>
                <span class="label label-success">正常</span>
              <?php else: ?>
                <span class="label label-warning">禁用</span>
              <?php endif ?>
            </td>
            <td><?= date('Y-m-d H:i:s', $row->created_at) ?></td>
            <td>
              <a href="<?= Yii::app()->createUrl('teacher/post_lesson', array('id' => $row->lesson_id)) ?>">编辑</a>
              <a href="<?=Yii::app()->createUrl('teacher/article',array('lesson_id'=>$row->lesson_id))?>">文章列表</a>
            </td>
          </tr>
        <?php endforeach ?>
      </table>
      <?php
      $this->widget('CLinkPager', array(
          'pages' => $data['pages'],
          'htmlOptions' => array(
              'class' => 'pagination'
          ),
          'firstPageLabel' => '首页',
          'lastPageLabel' => '末页',
          'nextPageLabel' => '下一页',
          'prevPageLabel' => '上一页',
          'footer' => '',
          'header' => '',
          'cssFile' => false
      ));
      ?>
    <?php endif ?>
  </div>
</div>
<script>
  $(function(){
    initiCheck();
    initList();
  });
</script>